# 线程对象及其他方法
from threading import Thread, current_thread, active_count
import os
import time


def task():
    print('sub', os.getpid())
    # 获取当前线程名字
    print(current_thread().name)
    time.sleep(1)


if __name__ == '__main__':
    t = Thread(target=task)
    t.start()

    # 统计当前活跃的进程数
    print(active_count())

    print('main', os.getpid())
    print(current_thread().name)
